package won.user;

import won.model.Book;
import won.model.User;
import won.page.BookPage;
import won.page.BorrowRecordPage;
import won.page.UserPage;

import java.util.Scanner;

import static java.lang.System.out;

public class HomeDisplay {
    Scanner input = new Scanner(System.in);
    public HomeDisplay(){
        AbstractUser user =  LoginDisplay.loginConsole();

        while(true){
            out.println("*******************图书管理系统 ******************");
            out.println("*                 【1】查询图书                  *");
            out.println("*                 【2】借阅图书                  *");
            out.println("*                 【3】归还图书                  *");
            out.println("*                 【4】添加新书                  *");
            out.println("*                 【5】删除图书                  *");
            out.println("*                 【0】退出系统                  *");
            out.println("*************************************************");
            out.print("请选择功能：");
            String select = input.nextLine();

            switch (select) {
                case "1":
                    out.print("Please input book name");
                    String bookName = input.nextLine();
                    BookManager.findBook(bookName);
                    break;
                case "2":
                    BookManager.borrowBook();
                    break;
                case "3":
                    BookManager.borrowBook();
                    break;
                case "4":
                    user.addBook();
                    break;
                case "5":
                    user.deleteBook();
                    break;
                case "6":
                    BookPage.modifyBook();
                    break;
                case "7":
                    BookPage.deleteBook();
                    break;
                case "8":
                    User newUser = UserPage.resetPassword();
                    user = newUser==null?user:newUser;
                    break;
                case "0":
                    out.println("*******************已退出系统!!!*****************");
                    System.exit(0);
                    break;
            }
        }

    }

}
